﻿/*
* 时间：2019年7月 
* 作者：潘意
*/
using HC.View;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using EMRView;
using EMRView.Extensions.HCAttribute;
using EMRView.Extensions.Command;

namespace EMRView.Extensions.Command.StandardCommand.Edit
{
    [Command(CommandType.编辑, "FontSize", "字体大小")]
    public class FontSizeCommand : BaseCommand
    {
        private readonly static string[] fontSize = new string[] { "初号", "小初", "一号", "小一", "二号", "小二", "三号", "小三",
                                                                   "四号","小四","五号","小五","六号","小六","七号","八号",
                                                                   "5","5.5","6.5","7.5","8","9","10","10.5",
                                                                   "11","12","14","16","18","20","22","24",
                                                                   "26","28","36","48","72"};

        public override Icon CommandIcon
        {
            get
            {
                return EMRView.Extensions.Properties.HCResource.默认;
            }
        }

        public override object Execute(HCEmrView view, bool showDefaultUI = false, params object[] para)
        {
            if (para == null)
            {
                return null;
            }
            view.ApplyTextFontSize(HC.View.HC.GetFontSize(para[0] as string));
            if (!view.Focused)
                view.Focus();
            return null;
        }

        public override void InitControl(object control)
        {
            if (control is ToolStripComboBox)
            {
                var fontSizeComboBox = control as ToolStripComboBox;
                fontSizeComboBox.Items.Clear();
                foreach (string size in fontSize)
                {
                    fontSizeComboBox.Items.Add(size);
                }
                fontSizeComboBox.SelectedIndex = fontSizeComboBox.Items.IndexOf("五号");
            }
        }
    }
}
